package com.bjtu.lms.action.system;

import com.bjtu.lms.model.Setting;
import com.bjtu.lms.service.SettingService;
import com.opensymphony.xwork2.ActionSupport;

public class GetSettingAction extends ActionSupport {
	
	private SettingService settingService;
	private String result;

	public SettingService getSettingService() {
		return settingService;
	}

	public void setSettingService(SettingService settingService) {
		this.settingService = settingService;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	@Override
	public String execute() throws Exception {
		Setting s = settingService.getSetting();
		if(s == null){
			result = "{suc:0, msg:'系统还没有数据'}";
		}else{
			result = "{" +
					"suc:1, " +
					"maxBorrow:'"+s.getMaxBorrow()+"',"+
					"maxDays:'"+s.getMaxDays()+"'"+
					"}";
		}
		return SUCCESS;
	}
}
